import datetime
import hashlib
import math
import os
import random
import statistics
import sys
import time
import uuid

num = 12.345
print(math.ceil(num))
print(math.modf(num))

print(random.choice(['hello', True, [1, 4, 5]]))
print(random.randrange(80, 100, 2))
print(random.random())

print(os.name)
print(os.getcwd())
print(os.listdir("d:/logs"))
# print(os.mkdir("d:/logs/test1"))

print(sys.argv[0])
print(sys.platform)
print(sys.path)

string = "123456"
m = hashlib.md5()  # 创建md5对象
m.update(string.encode(encoding='utf-8'))  # update方法只接收bytes类型数据作为参数
str_md5 = m.hexdigest()  # 得到散列后的字符串
print('MD5散列前为 ：' + string)
print('MD5散列后为 ：' + str_md5)

lst = [1, 4, 5, 7, 1, 3, 6, 9, 19]
print(statistics.mean(lst))  # 算数平均值
print(statistics.harmonic_mean(lst))  # 调和平均值
print(statistics.median(lst))  # 中位数
print(statistics.median_low(lst))  # 数据的第一个中位数（总数为偶数时有两个中位数）
print(statistics.median_high(lst))  # 数据的第二个中位数

print(uuid.uuid1())
print(uuid.uuid3(uuid.NAMESPACE_DNS, 'coolpython'))
print(uuid.uuid4())
print(uuid.uuid5(uuid.NAMESPACE_DNS, 'coolpython'))

print(time.time())
print(time.localtime(time.time()).tm_year)
print(time.localtime(time.time()).tm_mon)
print(time.localtime(time.time()).tm_mday)
print(time.clock())
time.sleep(2)
print(time.clock())
print(time.time())
print(time.localtime(time.time()))
print(time.gmtime(time.time()))
print(time.asctime(time.localtime()))
print(time.ctime(time.time()))
print(datetime.datetime.now())
print(datetime.datetime.now().strftime("%Y-%m-%d"))
